      *> File Name     000026_Drives.cbl.
      *> Description   Getting drive information (System.IO.DriveInfo).
      *> Project Type  Console Application.
      *> CodePlex URL  http://cobol.codeplex.com

       program-id.   Main.
       repository.
          class sys-console    as "System.Console"
          class drive-info     as "System.IO.DriveInfo"
          class io-exception   as "System.IO.IOException"
          class auth-exception as "System.UnauthorizedAccessException"
          class sec-exception  as "System.Security.SecurityException"
          .
       working-storage section.
       01  drives    drive-info occurs any.
       01  drive     drive-info.
       01  io-err    io-exception.
       01  auth-err  auth-exception.
       01  sec-err   sec-exception.
       procedure division.
           move "Enumerating Drives" to sys-console::"Title"

           invoke drive-info::"GetDrives" giving drives

           display "Drives:"
           perform varying drive through drives
               *> Some members of DriveInfo are always accessible.
               display "  Name: " drive::"Name"
               display "    Type : " drive::"DriveType"
               display "    Ready: " drive::"IsReady"

               *> Trying to access some of the other members such as
               *> TotalFreeSpace may raise an exception.
               display "    Free : " no advancing
               try
                   display drive::"TotalFreeSpace"
               catch io-err
                   display "System.IO.IOException - Is the drive ready?"
               catch auth-err
                   display "System.UnauthorizedAccessException"
               catch sec-err
                   display "System.Security.SecurityException"
               end-try
           end-perform

           display "Press any key to continue . . . " no advancing
           invoke sys-console::"ReadKey"(true)
           .
       end program   Main.